% Legendre Equal Weights (Pn-EW) Quadrature Set
clear,clc
% Let us try 12 polar angles, spaced evenly in ksi
disp('lala')
Nksi = 12;
N    = Nksi^2 * 2;

for i = 1:Nksi % Only compute positive polar
    ksi(i) = (2/Nksi)*(i-1/2)-1;
end

% now for the mu's
delksi = ksi(2)-ksi(1);

Nomega = round(N*delksi/2);

for j = 1:Nomega
    omega(j) = (j-0.5)*4*pi/N/delksi;
    for i = 1:Nksi
        mu(i,j)  = cos(omega(j)) * sqrt(1-ksi(i)^2);
        eta(i,j) = sin(omega(j)) * sqrt(1-ksi(i)^2); 
    end
end
% comput vectors of mu's, eta's, weights arranged by
%  [ -mu -eta w
%    +mu -eta w
%    -mu +eta w
%    +mu +eta w ]
k=0;

for j = Nomega/2+1:3*Nomega/4 % -mu -eta
    for i = Nksi/2+1:Nksi
        k=k+1;
        muwt(k,:)= [mu(i,j) eta(i,j) ksi(i) 8/N ];
    end
end
for j = 3*Nomega/4+1:Nomega % +mu -eta
    for i = Nksi/2+1:Nksi
        k=k+1;
        muwt(k,:)= [ mu(i,j) eta(i,j) ksi(i) 8/N ];
    end
end
for j = Nomega/4+1:Nomega/2 % -mu +eta
    for i = Nksi/2+1:Nksi
        k=k+1;
        muwt(k,:)= [ mu(i,j) eta(i,j) ksi(i) 8/N ];
    end
end 
for j = 1:Nomega/4 % +mu -eta
    for i = Nksi/2+1:Nksi
        k=k+1;
        muwt(k,:)= [ mu(i,j) eta(i,j) ksi(i) 8/N ];
    end
end